package icu.lookyousmileface.cas;


import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author starrysky
 * @title: CasABAProblem
 * @projectName Juc_Pro
 * @description: ABA问题, 立马换太子问题
 * @date 2021/1/308:03 下午
 */
public class CasABAProblem {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(20);

        //====================捣乱换太子=============
        atomicInteger.compareAndSet(20,66);
        atomicInteger.compareAndSet(66,20);
        //==================== 不知情的线程===========
        atomicInteger.compareAndSet(20,99);
        System.out.println(atomicInteger.get());
    }
}
